﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="gvProducts.aspx.cs" Inherits="gvProducts" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ProductID"
            DataSourceID="sdsProducts" AllowSorting="True" AllowPaging="True" AutoGenerateSelectButton="True"
            AutoGenerateDeleteButton="true" CellPadding="4" ForeColor="#333333" GridLines="None"
            OnDataBound="GridView1_DataBound" OnRowEditing="GridView1_RowEditing" OnPageIndexChanged="GridView1_PageIndexChanged"
            OnRowCreated="GridView1_RowCreated" OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
            <EditRowStyle BackColor="AliceBlue" />
            <AlternatingRowStyle BackColor="White" />
            <Columns>
                <asp:BoundField DataField="ProductID" HeaderText="ProductID" InsertVisible="False"
                    ReadOnly="True" SortExpression="ProductID" />
                <asp:BoundField DataField="ProductName" HeaderText="ProductName" SortExpression="ProductName" />
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:Label ID="lblProductName" runat="server" Text='<%#Eval("ProductName") %>'></asp:Label>
                    </ItemTemplate>
                    <HeaderTemplate>
                        PNameinTmplt
                    </HeaderTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="txtProductName" runat="server" Text='<%#Eval("ProductName") %>'></asp:TextBox>
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="SupplierID" HeaderText="SupplierID" SortExpression="SupplierID" />
                <asp:BoundField DataField="CompanyName" HeaderText="Supplier Name" SortExpression="CompanyName" />
                <asp:TemplateField>
                    <HeaderTemplate>
                        Company Name in Tplt
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:Label ID="lblCompanyName" runat="server" Text='<%#Eval("CompanyName") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:DropDownList ID="ddlCompany" runat="server" DataSourceID="sdsCompany" DataTextField="CompanyName"
                            DataValueField="SupplierID">
                        </asp:DropDownList>
                        <asp:SqlDataSource ID="sdsCompany" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
                            SelectCommand="SELECT [SupplierID] ,[CompanyName]FROM [Suppliers]"></asp:SqlDataSource>
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="CategoryID" HeaderText="CategoryID" SortExpression="CategoryID" />
                <asp:BoundField DataField="UnitPrice" HeaderText="UnitPrice" SortExpression="UnitPrice" />
                <asp:BoundField DataField="QuantityPerUnit" HeaderText="QuantityPerUnit" SortExpression="QuantityPerUnit"
                    ReadOnly="true" />
                <asp:BoundField DataField="UnitsInStock" HeaderText="UnitsInStock" SortExpression="UnitsInStock" />
                <asp:BoundField DataField="UnitsOnOrder" HeaderText="UnitsOnOrder" SortExpression="UnitsOnOrder" />
                <asp:BoundField DataField="ReorderLevel" HeaderText="ReorderLevel" SortExpression="ReorderLevel" />
                <asp:CheckBoxField DataField="Discontinued" HeaderText="Discontinued" SortExpression="Discontinued" />
                <asp:CommandField EditText="Click To Edit" ButtonType="Button" HeaderText="This is for Edit"
                    ShowEditButton="true" />
                    
                <asp:TemplateField>
                    <HeaderTemplate>
                        Value Of Stock
                    </HeaderTemplate>
                    <ItemTemplate>
                      
                        <asp:Label ID="lblTotal" runat="server" Text='<%#Convert.ToDecimal(Eval("UnitsInStock"))* Convert.ToDecimal(Eval("UnitPrice")) %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
            <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
            <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
            <SortedAscendingCellStyle BackColor="#FDF5AC" />
            <SortedAscendingHeaderStyle BackColor="#4D0000" />
            <SortedDescendingCellStyle BackColor="#FCF6C0" />
            <SortedDescendingHeaderStyle BackColor="#820000" />
        </asp:GridView>
        <asp:SqlDataSource ID="sdsProducts" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
            SelectCommand="SELECT Suppliers.CompanyName,Products.ProductID,Products.ProductName,Products.SupplierID,Products.CategoryID, 
                     Products.QuantityPerUnit,Products.UnitPrice,Products.UnitsInStock,Products.UnitsOnOrder,Products.ReorderLevel,Products.Discontinued
                     FROM Products INNER JOIN
                     Suppliers ON Products.SupplierID =Suppliers.SupplierID" UpdateCommand="UPDATE Products SET UnitPrice = @unitprice WHERE ProductID=@ProductID"
            DeleteCommand="DELETE Products WHERE ProductID=@ProductID"></asp:SqlDataSource>
        <br />
        <br />
        <asp:GridView ID="gvOrders" runat="server">
        </asp:GridView>
        <asp:SqlDataSource ID="sdsOrders" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>">
        </asp:SqlDataSource>
        <input type="checkbox" id="cbCheck" onselect="checkChange()" />
    </div>
    </form>
</body>
</html>
